# Contributor: Raed Rizqie <raed.rizqie@gmail.com>

_realname=jupyterlab
pkgbase=mingw-w64-python-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-python-${_realname}
pkgver=4.0.5
pkgrel=1
pkgdesc='JupyterLab computational environment (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url='https://jupyter.org/'
license=('spdx:BSD-3-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-async-lru"
         "${MINGW_PACKAGE_PREFIX}-python-ipykernel"
         "${MINGW_PACKAGE_PREFIX}-python-jupyter-lsp"
         "${MINGW_PACKAGE_PREFIX}-python-jupyter_notebook_shim"
         "${MINGW_PACKAGE_PREFIX}-python-jupyterlab-server")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-hatch-jupyter-builder"
             "${MINGW_PACKAGE_PREFIX}-python-installer")
options=('!strip')
source=(https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz)
sha256sums=('de49deb75f9b9aec478ed04754cbefe9c5d22fd796a5783cdc65e212983d3611')

prepare() {
  rm -rf python-build-${MSYSTEM} | true
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}"
}

build() {
  msg "Python build for ${MSYSTEM}"
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE ${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE
}
